package com.twentyOne.ClothingLand.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.twentyOne.ClothingLand.dao.BaseDAO;
import com.twentyOne.ClothingLand.dao.IPositionDAO;
import com.twentyOne.ClothingLand.vo.Position;

public class PositionDAO extends BaseDAO implements IPositionDAO {

	@Override
	public void addPosition(Position position) {
		
		Session session = getSession();
		Transaction tx = session.beginTransaction();
		session.save(position);
		tx.commit();
		session.close();
		
	}

	@Override
	public List<Position> searchAllPosition() {
		
		Session session = getSession();
		String hql = "from Position";
		Query query = session.createQuery(hql);
		List<Position> list = query.list();
		session.close();
		if(list.size() != 0)
			return list;
		else 
			return null;
		
	}

}
